package com.moleq.models;

import java.util.ArrayList;
import java.util.List;


public class AdapterDataSourceBuilder {
	
	public static  List<String> readValueFromTaxSettings( List<TaxSetting> settings){
		List<String> value = new ArrayList<String>();
		
		if (settings == null || settings.size() <= 0) {
			return value;
		}
		
		for (int i = 0; i < settings.size(); i++) {
			TaxSetting setting = settings.get(i);
			value.add("Tax " + setting.getTx_no());
		}
		
		return value;
	}
	
	public static List<String> readValueFromPrinterSetting( List<PrinterSetting> settings){
		List<String> value = new ArrayList<String>();
		
		if (settings == null || settings.size() <= 0) {
			return value;
		}
		
		for (int i = 0; i < settings.size(); i++) {
			PrinterSetting setting = settings.get(i);
			value.add(setting.getPs_name());
		}
		
		return value;
	}
	
	public static List<String> readValueFromRoundingSetting( List<RoundingSetting> settings){
		List<String> value = new ArrayList<String>();
		
		if (settings == null || settings.size() <= 0) {
			return value;
		}
		
		for (int i = 0; i < settings.size(); i++) {
			RoundingSetting setting = settings.get(i);
			value.add(setting.getRs_name());
		}
		
		return value;
	}
	
	public static List<String> readValueFromSettings(List<SettingSelection> settings) {

		List<String> value = new ArrayList<String>();

		if (settings == null || settings.size() <= 0) {
			return value;
		}

		for (int i = 0; i < settings.size(); i++) {
			SettingSelection setting = settings.get(i);
			value.add(setting.getValue());
		}

		return value;
	} 
	
	public static List<String> readValueFromGroup(List<Group> groups) {

		List<String> value = new ArrayList<String>();

		if (groups == null || groups.size() <= 0) {
			return value;
		}

		for (int i = 0; i < groups.size(); i++) {
			value.add(groups.get(i).getDg_name());
		}

		return value;
	}
	
	public static List<String> readValueFromSubDep(List<SubDepartmant> subDeps) {
		List<String> value = new ArrayList<String>();
		if (subDeps != null ) {
			for (int i = 0; i < subDeps.size(); i++) {
				value.add(subDeps.get(i).getSd_name());
			}
		}
		return value;
	}
	
	public static List<String> readValueFromDep(List<Departmant> deps) {
		List<String> value = new ArrayList<String>();
		if (deps != null ) {
			for (int i = 0; i < deps.size(); i++) {
				value.add(deps.get(i).getDep_name());
			}
		}
		return value;
	}
	
	public static List<String> readValueFromCustomerSetting(List<CustomerSetting> setup){
		List<String> value = new ArrayList<String>();
		if (setup != null ) {
			for (int i = 0; i < setup.size(); i++) {
				String display = setup.get(i).getCs_no() + "   " 
						+ setup.get(i).getCs_first_name() + "   " 
						+ setup.get(i).getCs_last_name();
				value.add(display);
			}
		}
		return value;
	}

	public static List<List<String>> readValueFromSubDept(List<SubDepartmant> subDept) {
		List<List<String>> list = new ArrayList<List<String>>();
		List<String> columns = null;
		if (subDept != null) {
			for (int i = 0; i < subDept.size(); i++) {
				columns = new ArrayList<String>();
				columns.add(String.valueOf(subDept.get(i).getSd_id()));
				columns.add(subDept.get(i).getSd_name());

				if (subDept.get(i).getTax1() || 
					subDept.get(i).getTax2() || 
					subDept.get(i).getTax3() || 
					subDept.get(i).getTax4() || 
					subDept.get(i).getTax5() || 
					subDept.get(i).getTax6()) {
					columns.add("1");
				} else {
					columns.add("0");
				}
				columns.add(String.valueOf(subDept.get(i).getFood_stamp() ? 1 : 0));
				columns.add(String.valueOf(subDept.get(i).getScale_weight() ? 1 : 0));
				list.add(columns);
			}
		}
		return list;
	}
	
	public static List<List<String>> readValueFromDept(List<Departmant> dept){
		List<List<String>> list = new ArrayList<List<String>>();
		List<String> columns = null;
		if (dept != null) {
			for (int i = 0; i < dept.size(); i++) {
				columns = new ArrayList<String>();
				columns.add(String.valueOf(dept.get(i).getDep_no()));
				columns.add(dept.get(i).getDep_name());

				if (dept.get(i).getTax1() || 
						dept.get(i).getTax2() || 
						dept.get(i).getTax3() || 
						dept.get(i).getTax4() || 
						dept.get(i).getTax5() || 
						dept.get(i).getTax6()) {
					columns.add("1");
				} else {
					columns.add("0");
				}
				columns.add(String.valueOf(dept.get(i).getFood_stamp() ? 1 : 0));
				columns.add(String.valueOf(dept.get(i).getScale_weight() ? 1 : 0));
				list.add(columns);
			}
		}
		return list;
	}
}
